package com.woniuxy.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.config.ResponseResult;
import com.woniuxy.entity.Movie;
import com.woniuxy.service.MovieService;
import com.woniuxy.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/movie")
public class MovieController {

    @Autowired
    private MovieService movieService;
    @GetMapping("new")
    public ResponseResult<List<Movie>> ByNew(int new_category){
       List<Movie> list = movieService.ByNew(new_category);
        return new ResponseResult<>(list);
    }
    @GetMapping("ByCategoryId")
    public ResponseResult<PageBean<Movie>> ByCategoryId(int categoryId,Integer p,int n){
        if(categoryId==0){
            PageBean<Movie> listall=movieService.all(p,n);
            return new ResponseResult<>(listall);
        }
        PageBean<Movie> list = movieService.ByCategoryId(categoryId,p,n);
        return new ResponseResult<>(list);
    }
    @GetMapping("runk")
    public ResponseResult<List<Movie>> ByRunk(){
        return new ResponseResult<>(movieService.ByRunk());
    }

}
